/*
 * Project Name: micro
 * Create Time: 2017/8/23 21:46
 * Copyright ©2017, billson0618@163.com All Rights Reserved.
 */
package pers.billson.micro.service.common.impl;

import org.springframework.beans.factory.annotation.Autowired;
import pers.billson.micro.mapper.common.BaseMapper;
import pers.billson.micro.service.common.BaseService;

import java.util.List;

/**
 * TODO 一句话简单描述这个类是什么<br>
 *
 * @author Billson
 * Create Time: 2017/8/23 21:46
 */
public class BaseServiceImpl<T> implements BaseService<T> {

    @Autowired
    private BaseMapper baseMapper;

    /**
     * 根据主键id删除一条数据<br>
     *
     * @param id 主键id
     * @author Billson
     * Create Time: 2017/8/23 21:12
     */
    @Override
    public int deleteByPrimaryKey(String id) {
        return this.baseMapper.deleteByPrimaryKey(id);
    }

    /**
     * 新增一条数据，不过滤为null的字段<br>
     *
     * @param record 实体对象
     * @author Billson
     * Create Time: 2017/8/23 21:11
     */
    @Override
    public int insert(T record) {
        return this.baseMapper.insert(record);
    }

    /**
     * 新增一条数据，过滤为null的字段<br>
     *
     * @param record 实体对象
     * @author Billson
     * Create Time: 2017/8/23 21:25
     */
    @Override
    public int insertSelective(T record) {
        return this.baseMapper.insertSelective(record);
    }

    /**
     * 根据主键id查询一条数据<br>
     *
     * @param id 主键id
     * @author Billson
     * Create Time: 2017/8/23 21:15
     */
    @Override
    public T selectByPrimaryKey(String id) {
        return (T) this.baseMapper.selectByPrimaryKey(id);
    }

    /**
     * 查询所有数据<br>
     *
     * @author Billson
     * Create Time: 2017/8/23 21:15
     */
    @Override
    public List<T> list() {
        return this.baseMapper.list();
    }

    /**
     * 根据主键id更新一条数据，过滤为null的字段<br>
     *
     * @param record 更新的实体对象
     * @author Billson
     * Create Time: 2017/8/23 21:27
     */
    @Override
    public int updateByPrimaryKeySelective(T record) {
        return this.baseMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据主键id更新一条数据，不过滤为null的字段<br>
     *
     * @param record 更新的实体对象
     * @author Billson
     * Create Time: 2017/8/23 21:13
     */
    @Override
    public int updateByPrimaryKey(T record) {
        return this.baseMapper.updateByPrimaryKey(record);
    }
}
